<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /***
         *        *
         *       ***
         *      *****
         *     *******
         *    *********
         * 
         *   行      列空格     列*
         *   i         j         k  = 2 * i - 1
         *   1         4         1  = 2 * 1 - 1   
         *   2         3         3  = 2 * 2 - 1
         *   3         2         5  = 2 * 3 - 1
         *   4         1         7
         *   5         0         9
         * 
         */

        for (var i = 1; i <= 5; i++) {
            // for循环控制打印空格
            for (var j = 1; j <= 5 - i; j++) {
                document.write('&ensp;');
            }
            // for循环控制打印 *
            for(var k = 1; k <= 2 * i - 1; k++){
                document.write('*');
            }
            document.write('<br/>');
        }
    </script>
</body>

</html>